#!/usr/bin/env rake

begin
   require "bundler/gem_tasks"
rescue Exception
   sh 'gem install bundler --version "~> 1.3.1" --no-rdoc --no-ri'
end

Bundler::GemHelper.install_tasks

desc 'Update dependencies'
task :up do
   sh 'bundle update'
end

desc 'Make css'
task :css do
   require 'less'
   parser = Less::Parser.new :paths => ['less']
   tree = parser.parse(IO.read('less/bootstrap.less'))
   ::File.open("css/bootstrap.css",'w') do |f|
      f.puts tree.to_css
   end
   ::File.open("css/bootstrap.min.css",'w') do |f|
      f.puts tree.to_css(:compress => true)
   end
end

desc "Build the gem"
task :build do
   sh 'gem build twitter-bootstrap-ruby.gemspec'
end

desc "Bundle the gem"
task :bundle do
   require File.expand_path( '../lib/twitter/bootstrap/version', __FILE__ )
   sh "gem install twitter-bootstrap-ruby-#{Twitter::Bootstrap::VERSION}.gem"
end

task(:default).clear
task :build => :css
task :bundle => :build
task :release => :build
task :default => :bundle

